package com.springboot.framework.handler;


import com.springboot.framework.exception.BaseException;
import com.springboot.framework.response.ResponseMap;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class MyExceptionHandler {

    /*处理自定义异常*/
    @ExceptionHandler(value = BaseException.class)
    @ResponseBody
    public ResponseMap exceptionHandler(BaseException e){
        return new ResponseMap().fail(e.getMessage());
    }
}
